package com.linhh.mall.center.server.service;

import com.linhh.mall.center.api.RoleInfoService;
import com.linhh.mall.center.common.pojo.RoleInfo;
import com.linhh.mall.center.server.mappers.RoleInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * RoleInfoService接口实现类
 * @Author linhh
 * @Date 2022 10 19 15 38
 **/
@Service
public class RoleInfoServiceImpl implements RoleInfoService {

    @Autowired
    private RoleInfoMapper roleInfoMapper;

    @Override
    public List<RoleInfo> selectRoleByUserId(Long userId) {
        return roleInfoMapper.selectRoleByUserId(userId);
    }

    @Override
    public List<RoleInfo> selectAll() {
        return roleInfoMapper.selectAll();
    }

    @Override
    public int addRole(RoleInfo info) {
        roleInfoMapper.insertSelective(info);
        return 1;
    }

    @Override
    public int deleteRole(Long id) {
        roleInfoMapper.deleteByPrimaryKey(id);
        return 1;
    }

    @Override
    public int updateRole(RoleInfo roleInfo) {
        roleInfoMapper.updateByPrimaryKeySelective(roleInfo);
        return 1;
    }

}
